import { mergeOptions } from "../options";

export function initExtend(Vue) {
    let cid = 0;
    Vue.extend = function (definition) {
        const Super = this;
        let Sub = function (options) {
            this._init(options);
        }
        Sub.cid = cid++;
        Sub.prototype = Object.create(Super.prototype);
        Sub.prototype.constructor = Sub;
        // 将父类的options和组件的配置进行合并 
        // 并且将Vue.options上的全局组件合并到这
        Sub.options = mergeOptions(Super.options, definition);

        return Sub;
    }
}

